package com.wwwc.index.web.servlet;

import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.ServletRequestWrapper;
import java.net.*;

public class DebugBean {

    public static StringBuffer getInputParameters(HttpServletRequest request) 
    {
	StringBuffer sbf = new StringBuffer("");
	try {
	    String name = null;
	    Enumeration enum = request.getParameterNames();
	    while(enum.hasMoreElements()) {
		name  = (String)enum.nextElement();
		sbf.append("<BR>\n"+name+" = "+request.getParameter(name));
	    }
	}
	catch(Exception e) {
	    return sbf.append("<BR>\nError["+e+"]");
	}
	return sbf;
    }

    public static StringBuffer getInputs(String call_from, HttpServletRequest request) 
    {
	HttpSession session = request.getSession(true);
	StringBuffer sbf = new StringBuffer("");
	try {
	    String name = null;
	    Enumeration enum = request.getParameterNames();
	    sbf.append("\n<BR>Call Form:"+call_from+"====================<start>====================");
	    sbf.append("\n<BR><BR>=====Request Parameters:");
	    while(enum.hasMoreElements()) {
		name  = (String)enum.nextElement();
		sbf.append("\n<BR>\n"+name+" = "+request.getParameter(name));
	    }

	    enum = request.getAttributeNames();
	    sbf.append("\n<BR><BR>=====Request Attributes:");
	    while(enum.hasMoreElements()) {
		name  = (String)enum.nextElement();
		sbf.append("\n<BR>"+name+" = "+request.getAttribute(name));
	    }

	    enum = session.getAttributeNames();
	    sbf.append("\n<BR><BR>=====Session Attributes:");
	    while(enum.hasMoreElements()) {
		name  = (String)enum.nextElement();
		sbf.append("\n<BR>"+name+" = "+session.getAttribute(name));
	    }
	    sbf.append("\n<BR>Call Form:"+call_from+"====================<end>====================");
	}
	catch(Exception e) {
	    return sbf.append("\n<BR>\nError["+e+"]");
	}
	return sbf;
    }

    public static StringBuffer getInputParameters(String call_from, HttpServletRequest request) 
    {
	StringBuffer sbf = new StringBuffer("");
	try {
	    String name = null;
	    Enumeration enum = request.getParameterNames();
	    sbf.append("\n<BR>Call Form:"+call_from+"====================<start>====================");
	    sbf.append("\n<BR>Request Parameters:");
	    while(enum.hasMoreElements()) {
		name  = (String)enum.nextElement();
		sbf.append("\n<BR>\n"+name+" = "+request.getParameter(name));
	    }
	    sbf.append("\n<BR>Call Form:"+call_from+"====================<end>====================");
	}
	catch(Exception e) {
	    return sbf.append("\n<BR>\nError["+e+"]");
	}
	return sbf;
    }
}






